<template>
	<view class="mainpadding2">
		<view class="flexbetween xiaobai main_size mainpadding" style="background-color: #ed4d2d;">
			<view class="flexleft">
				<u-icon name="map" color="#ffffff" size="16"></u-icon>
				<text class="  margin_left1">臺中市西屯區</text>
			</view>
			<u-icon name="arrow-down" color="#fff" size="16"></u-icon>
		</view>
		<view class="mainpadding_top ffffff radius shadow">
			<view class="flexbetween">
				<view class="flexleft">
					<view class="hong_text titletext bold margin-right">#1</view>
					<view class="xiaohei main_size">2025-09-06 09:06</view>
				</view>
				<view class="submitbtn" style="width: 25%;background-color: #e56969;font-size: 24rpx;padding: 15rpx 40rpx;color: #fff;" >轉需求</view>
			</view>
			<view class="flexbetween margin_top2">
				<view class="flexleft">
					<u-icon name="account" color="#ff8505" size="16"></u-icon>
					<view class="hei_text main_size margin_left1">張三 18574745858</view>
				</view>
				<view class="flexleft">
					<image @click.stop="daohang()" class="shopPhone" src="@/static/image/system/navigation.png" mode="">
					</image>
					<image class="shopPhone margin_left1" src="@/static/image/system/phoneShop.png" mode=""
						@click.stop="phone()"></image>
				</view>
			</view>
			<view class="margin_top2 flexleft">
				<u-icon name="map" color="#ff8505" size="16"></u-icon>
				<text class="hei_text main_size margin_left1">台灣省臺中市西屯區525號</text>
			</view>
			<view class="flexbetween margin_top2">
				<view class="huang_text main_size">產品</view>
				<u-icon name="arrow-down" color="#333" size="16"></u-icon>
			</view>
			<view v-for="(item,index) in 3">
				<view class="margin_top2 hei_text main_size">
					{{index+1}}.產品名稱產品名稱產品名稱產品名稱產品名稱產品名稱
				</view>
				<view class="flexright">
					<view class="submitbtn" style="width: 25%;font-size: 24rpx;padding: 15rpx 0;" @click="show=true">上傳照片</view>
				</view>
			</view>
		</view>
		<u-modal :show="show" title="拍照上傳" confirmColor="#ffb800" confirmText="確認" @confirm="upconfirm" cancelText="取消"
			@cancel="show=false" showCancelButton>
			<view class="slot-content" style="width: 730rpx;">
				<view class="flexleft flex_wrap">
					<view class="itemimgBox flexcenter margin_top2" v-for="(item,index) in images_text" :key="index">
						<!-- 已上传 -->
						<view class="listleftimg1 radius">
							<image class="radius" :src="item" mode=""></image>
							<view class="deleteimg" @click="delindex(index,images,images_text)"></view>
						</view>
					</view>
					<view class="itemimgBox flexcenter margin_top2" @click="uploadImg(3,images,images_text)"
						v-if="images.length<3"><!-- 未上传 -->
						<image class="listleftimg1 radius" src="@/static/image/system/upimg.png" mode=""></image>
					</view>
				</view>
			</view>
		</u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				images: [],
				images_text: [],
			}
		},
		methods: {
			uploadImg(value, upImgs, upImgs_text) { //上传图片
				let _this = this;
				let num = Number(value) - upImgs.length;
				if (num <= 0) {
					return false;
				}
				this.http.chooseImage(num, ['camera']).then(res => {
					for (var i = 0; i < res.length; i++) {
						_this.uploadImageService(res[i], upImgs, upImgs_text)
					}
				}).catch(err => {});
			},
			delindex(index, upImg, upImgs_text) {
				upImg.splice(index, 1)
				upImgs_text.splice(index, 1)
			},
			uploadImageService(url, upImg, upImgs_text) {
				let _this = this;
				this.http.uploadFile('/api/common/upload', url).then(res => {
					let image_item = res.fullurl;
					upImg.push(res.url)
					upImgs_text.push(image_item);
				}).catch(err => {});
			},
		}
	}
</script>

<style lang="scss" scoped>
.listleftimg1{
		width: 120rpx;
		height: 120rpx;
		position: relative;
		image{
			width: 100%;
			height: 100%;
		}
	}
</style>